//
//  InvestmentContentViewController.m
//  投融保
//
//  Created by wangan on 13-12-18.
//  Copyright (c) 2013年 木叶科技. All rights reserved.
//

#import "InvestmentContentViewController.h"
#import "SureTouZi.h"
#import "MYLoginViewController.h"
#import "MYRecommendViewController.h"
#import "UIImageView+WebCache.h"
@interface InvestmentContentViewController ()

@end

@implementation InvestmentContentViewController
@synthesize scroller,processLable,proKind,proStatus,proTitle,endTime,starTime,shouYiYearLable,haiChaLable,heTongNo,manZuLale,yiTouZiLable,rongZiTime,leastShouYi,jieShouUser,danBaoNO,proXinXi,xuQiuMoney,jiGouLabe,danBaoHanImage,jiGouHuaYu;
NSDictionary *touZiDic;
extern float j;
NSString *proToken;
bool loginFlag;
extern NSDictionary *loginDic;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        
        self.view.backgroundColor= [UIColor blackColor];
        //scroller.frame= CGRectMake(0, 63, 320, 568);
        scroller.contentSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT+700);
        
    }
    return self;
}

- (void)viewDidLoad

{
    [super viewDidLoad];
    
    self.progress.progress = j/100;
    int i  = j;
    self.processLable.text=[NSString stringWithFormat:@"%d%%",i];
    self.processLable.font = [UIFont systemFontOfSize:18];
    mbHud = [[MBProgressHUD alloc] initWithView:self.view];
    mbHud.labelText = @"正在加载";
    [self.view addSubview:mbHud];
    mbHud.delegate = self;
    [mbHud show:YES];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getdata:)   name:@"getAsyData" object:nil];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    
    
}
-(void)getdata:(NSNotification *)object{
    
    touZiDic = [object object];
    proToken = [touZiDic valueForKey:@"token"];
    NSLog(@"%@",touZiDic);
    [self setvalueForView];
    sleep(1);
    [mbHud removeFromSuperview];
    
}
-(void)setvalueForView{
    if ([touZiDic valueForKey:@"contractNo"]==nil) {
        heTongNo.text = @"待成立";
    }else{
        heTongNo.text = [touZiDic valueForKey:@"contractNo"];
    }
    if ([[touZiDic valueForKey:@"proStatus"]integerValue]==1) {
        proStatus.text = @"待成立";
    }else{
        proStatus.text = @"已完成";
    }
    proKind.text = [touZiDic valueForKey:@"loanPurpose"];
    starTime.text = [NSString stringWithFormat:@"%@",[touZiDic valueForKey:@"investAvalibleTime"]];
    endTime.text = [NSString stringWithFormat:@"%@",[touZiDic valueForKey:@"deadline"]];
    haiChaLable.text = [NSString stringWithFormat:@"%@元",[touZiDic valueForKey:@"investableAmount"]];
    proTitle.text = [touZiDic valueForKey:@"selfDefinedTitle"];
    proXinXi.text = [touZiDic valueForKey:@"loanNote"];
    danBaoNO.text = [touZiDic valueForKey:@"guaranteeLicenseNo"];
    xuQiuMoney.text = [NSString stringWithFormat:@"%@元",[touZiDic valueForKey:@"loanAmount"]];
    jieShouUser.text = [touZiDic valueForKey:@"userName"];
    shouYiYearLable.text = [NSString stringWithFormat:@"%@",[touZiDic valueForKey:@"interestRate"]];
    yiTouZiLable.text = [NSString stringWithFormat:@"%@元",[touZiDic valueForKey:@"loanedAmount"]];
    haiChaLable.text = [NSString stringWithFormat:@"%@元",[touZiDic valueForKey:@"investableAmount"]];
    leastShouYi.text = [NSString stringWithFormat:@"%@元",[touZiDic valueForKey:@"leastInvestAmount"]];
    rongZiTime.text = [touZiDic valueForKey:@"timeLimit"];
    manZuLale.text = [touZiDic valueForKey:@"saturationCondition"];
    jiGouHuaYu.text = [touZiDic valueForKey:@"guaranteeStatement"];
    //担保han路径
    //http://ppm.yijifu.net:8607/upload/getUploadImages?imagePath=/home/19finance/upload/eloan/upload-pic/2014-01/images/1388826245976.jpg
    NSString *danbaoUrl =[touZiDic valueForKey:@"guaranteeLicenseUrl"];
    NSLog(@"danbaoUrl-----%@",danbaoUrl);
    
    jiGouLabe.text = [touZiDic valueForKey:@"guaranteeName"];
    [danBaoHanImage setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://ppm.yijifu.net:8607%@",danbaoUrl]] placeholderImage:nil];
}
//－－修改
- (IBAction)touZiBtn:(UIButton *)sender {
    if ([[loginDic valueForKey:@"code"] integerValue]!=0) {
        [self presentViewController:[SureTouZi new] animated:YES completion:nil];
        
    }else {
        [self presentViewController:[MYLoginViewController new] animated:NO completion:nil];
        loginFlag=true;
    }
    
}

- (IBAction)backBtn:(UIButton *)sender {
    if ([[loginDic valueForKey:@"code"] integerValue]==1) {
        if (loginFlag==true) {
            [self presentViewController:[MYRecommendViewController new] animated:NO completion:nil];
        }else {
            [self dismissViewControllerAnimated:YES completion:nil];
        }
        
    }else{
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    
}
#pragma mark-   -----------状态栏底色------
- (UIStatusBarStyle)preferredStatusBarStyle
{
    [self.view setBackgroundColor:[UIColor blackColor]];
    return UIStatusBarStyleLightContent;
}
- (BOOL)prefersStatusBarHidden
{
    return NO;
}
@end
